/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package actions;

import com.paris5.master2.guitarmaster.bean.EcomScore;
import com.paris5.master2.guitarmaster.bean.EcomUser;
import com.paris5.master2.guitarmaster.exception.EcomException;
import com.paris5.master2.guitarmaster.exception.EcomQueryException;
import com.paris5.master2.guitarmaster.exception.EcomValidationException;
import com.paris5.master2.guitarmaster.service.ServiceProductRemote;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts2.interceptor.ServletRequestAware;

/**
 *
 * @author Alice
 */
public class Noter extends EcomAction implements ServletRequestAware {
    private EcomScore score;
    private int idProduct;
    private String valeur;
    HttpServletRequest request;

    public EcomScore getScore() {
        return score;
    }

    public void setScore(EcomScore score) {
        this.score = score;
    }

    public int getIdProduct() {
        return idProduct;
    }

    public void setIdProduct(int idProduct) {
        this.idProduct = idProduct;
    }

    @Override
    public void setServletRequest(HttpServletRequest request) {
        this.request = request;
    }

    public String getValeur() {
        return valeur;
    }

    public void setValeur(String valeur) {
        this.valeur = valeur;
    }

    @Override
    public String execute() {
        try {        
            ServiceProductRemote serviceProductRemote = lookupServiceProductRemote();
             valeur = request.getParameter("val");
            
             idProduct = (int) Double.parseDouble(request.getParameter("idProd"));
             //System.out.println("iciiiii________" + idProduct + " valeur " + valeur);
            
          
          if("up".equals(valeur)){
              System.out.println("UP VALUE");
              score = serviceProductRemote.setProductTypeScore(idProduct, true);
          }else{
               System.out.println("DOWN VALUE");
               score = serviceProductRemote.setProductTypeScore(idProduct, false);
          }
            return SUCCESS;
        } catch (EcomValidationException ex) {
            Logger.getLogger(Noter.class.getName()).log(Level.SEVERE, null, ex);
        }
          return ERROR;

       
      


    }
}
